package graph;

import java.awt.Point;
import java.util.LinkedList;
import java.util.NoSuchElementException;

public class LinkedNodeList<E extends Node> extends LinkedList<Node> {

	public boolean IsThereANodeAtPoint(Point here) {
		if(here == null || this.size() == 0)
			return false;
		
		if(contains(new Node(here))) 
			return true;
		
		return false;
	}
	
	public E getNodeAt(Point point) {
		if(point == null || this.size() == 0) 
			throw new NoSuchElementException("No node at point " + point);
		
		for(Node node : this) {
			if(node.getLocation().equals(point)) 
				return (E)node; // TODO Potential bug
		}
		throw new NoSuchElementException("No node at point " + point);
	}
}
